package com.songlanyun.modules.openSwitch.controller;

import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletResponse;

import com.songlanyun.common.utils.R;
import com.songlanyun.modules.openSwitch.domain.YxtSwitch;
import com.songlanyun.modules.openSwitch.service.IYxtSwitchService;
import lombok.extern.java.Log;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 余额支付开关Controller
 * 
 * @author mx
 * @date 2024-02-27
 */
@RestController
@RequestMapping("/admin/yxt/switch")
public class YxtSwitchController
{
    @Autowired
    private IYxtSwitchService yxtSwitchService;

    /**
     * 查询余额支付开关列表
     */
    @GetMapping("/list")
    public R list(YxtSwitch yxtSwitch)
    {
        List<YxtSwitch> list = yxtSwitchService.selectYxtSwitchList(yxtSwitch);
        return R.ok().put("data", list);
    }

    @GetMapping(value = "/{id}")
    public R getInfo(@PathVariable("id") Long id)
    {
        return R.ok().put("data", yxtSwitchService.selectYxtSwitchById(id));
    }


    /**
     * 修改余额支付开关
     * @RequestBody Map<String, SwitchData> requestData
     */
    @PutMapping
    public R edit(@RequestBody Map<String, YxtSwitch> yxtSwitch)
    {
        YxtSwitch yxtSwitchData = yxtSwitch.get("data");
        System.out.println(yxtSwitchData.getBalanceSwitch());
        System.out.println(yxtSwitchData.getBalanceExchangeAssport());
        System.out.println(yxtSwitchData.getId());
        yxtSwitchService.updateYxtSwitch(yxtSwitchData);
        return R.ok();
    }

    /**
     * 删除余额支付开关
     */
	@DeleteMapping("/{ids}")
    public R remove(@PathVariable Long[] ids)
    {
        return R.ok().put("data", yxtSwitchService.deleteYxtSwitchByIds(ids));
    }
}
